//
//  CustomTableViewCell.m
//  22作业
//
//  Created by dllo on 16/8/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CustomTableViewCell.h"

#define width self.bounds.size.width
#define height self.bounds.size.height
@implementation CustomTableViewCell

//- (instancetype)init
//{
//    self = [super init];
//    if (self) {
//        _button = [UIButton buttonWithType:UIButtonTypeCustom];
//    }
//    return self;
//}
//
//- (instancetype)initWithFrame:(CGRect)frame
//{
//    self = [super initWithFrame:frame];
//    if (self) {
//        _button = [UIButton buttonWithType:UIButtonTypeCustom];
//    }
//    return self;
//}
//
//- (instancetype)initWithCoder:(NSCoder *)aDecoder
//{
//    self = [super initWithCoder:aDecoder];
//    if (self) {
//        _button = [UIButton buttonWithType:UIButtonTypeCustom];
//    }
//    return self;
//}


- (void)layoutSubviews
{
    [super layoutSubviews];
    _collection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 200, width, 200) collectionViewLayout:_flow];
    
    _customView = [[CustomView alloc] initWithFrame:CGRectMake(0, 50, width, 100)];
    _customView1 = [[CustomView1 alloc] initWithFrame:CGRectMake(0, 0, width, 50)];
    _customView2 = [[CustomView2 alloc] initWithFrame:CGRectMake(0, 0, width, 100)];
    
    
    _collection.delegate = self;
    _collection.dataSource = self;

    [_collection registerClass:[CustomCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    _flow.itemSize = CGSizeMake((width - 10) / 2, 80);
    _flow.minimumInteritemSpacing = 5;
    _flow.minimumLineSpacing = 5;
    _flow.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
    [self addSubview:_collection];
    [self addSubview:_customView];
    [self addSubview:_customView1];
    
    [self addSubview:_customView2];

}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 4;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CustomCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    return cell;
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
